#include <iostream>
#include <map>
using namespace std;

map<int, int> level;

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int input;
        cin >> input;
        map<int, int>::iterator it = level.find(input);
        if (it != level.end())
        {
            // 有该能力的人
            it->second++;
        }
        else
        {
            level.insert(make_pair(input, 1));
        }
    }
    map<int, int>::iterator it = level.begin();
    cout << it->first << " " << it->second << endl;
    it = level.end();
    it--;
    cout << it->first << " " << it->second << endl;
    return 0;
}